//
//  DiseaseViewController.m
//  KMedicine
//
//  Created by 452608533 on 16/7/7.
//  Copyright © 2016年 caomu. All rights reserved.
//

#import "DiseaseViewController.h"
#import "WJZDYButton.h"
#import "InessTableViewController.h"
#import "ClassificationOfDiseaseController.h"

@interface DiseaseViewController ()
@property(nonatomic,weak)UILabel *userLabel;
@property(nonatomic,weak)UILabel *nameLabel;
@property(nonatomic,weak)UILabel *typeLabel;
@property(nonatomic,weak)UILabel *diseseLabel;
@property(nonatomic,weak)WJZDYButton *selDisButton;
@property(nonatomic,weak)WJZDYButton *moreSelButton;
//@property(nonatomic,weak)UITextField *tf_separated;
//@property(nonatomic,weak)UIView *lineView;
//@property(nonatomic,weak)UIImageView *imageView;

@property (nonatomic, copy) NSString *name;

@end

@implementation DiseaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupUI];
}

- (void)setupUI {
    
    self.view.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1];
    
    //userLabel
    UILabel *userLabel = [[UILabel alloc]init];
    self.userLabel = userLabel;
    userLabel.text = @"用户信息:";
    [userLabel setTextAlignment:NSTextAlignmentCenter];
    NSDictionary *userDict = @{NSFontAttributeName:[UIFont fontWithName:@"Heiti SC" size:20]};
    NSAttributedString *attr1 = [[NSAttributedString alloc]initWithString:userLabel.text attributes:userDict];
    [userLabel setAttributedText:attr1];
    userLabel.numberOfLines=0;
    [userLabel setTextAlignment:NSTextAlignmentLeft];
    [self.view addSubview:userLabel];
    
    //nameLabel
    UILabel *nameLabel = [[UILabel alloc]init];
    self.nameLabel = nameLabel;
    nameLabel.text = @"王二狗1000099";
    NSDictionary *nameDict = @{NSAttachmentAttributeName:[UIFont fontWithName:@"Heiti SC" size:19]};
    NSAttributedString *attr2 = [[NSAttributedString alloc]initWithString:nameLabel.text attributes:nameDict];
    [nameLabel setAttributedText:attr2];
    nameLabel.numberOfLines=0;
    [nameLabel setTextAlignment:NSTextAlignmentLeft];
    [self.view addSubview:nameLabel];
    
    //typeLabel
    UILabel *typeLabel = [[UILabel alloc]init];
    self.typeLabel = typeLabel;
    typeLabel.text = @"疾病类型:";
    NSDictionary *typeDict = @{NSFontAttributeName:[UIFont fontWithName:@"Heiti SC" size:20]};
    NSAttributedString *attr3 = [[NSAttributedString alloc]initWithString:typeLabel.text attributes:typeDict];
    [typeLabel setAttributedText:attr3];
    typeLabel.numberOfLines = 0;
    [nameLabel setTextAlignment:NSTextAlignmentLeft];
    [self.view addSubview:typeLabel];
    
    //diseseLabel
    UILabel *diseseLabel = [[UILabel alloc]init];
    self.diseseLabel = diseseLabel;
   self.diseseLabel.text = self.title;
    NSDictionary *diseseDict = @{NSFontAttributeName:[UIFont fontWithName:@"Heiti SC" size:19]};
    NSAttributedString *attr4 = [[NSAttributedString alloc]initWithString:diseseLabel.text attributes:diseseDict];
    [diseseLabel setAttributedText:attr4];
    diseseLabel.numberOfLines = 0;
    [diseseLabel setTextAlignment:NSTextAlignmentLeft];
    [self.view addSubview:diseseLabel];
    
    //疾病细分
    WJZDYButton *selDisButton = [[WJZDYButton alloc]initWithPlaceHolder:@"请选择疾病细分"];
    self.selDisButton = selDisButton;
    [self.view addSubview:selDisButton];
    
    //选择并发症
    WJZDYButton *moreSelButton = [[WJZDYButton alloc]initWithPlaceHolder:@"请选择并发症(可多选)"];
    self.moreSelButton = moreSelButton;
    [self.view addSubview:moreSelButton];
    
    //    添加按钮监听
    [selDisButton addTarget:self action:@selector(didClikSelButton:) forControlEvents:UIControlEventTouchUpInside];
    [moreSelButton addTarget:self action:@selector(didClikMoreSelButton:) forControlEvents:UIControlEventTouchUpInside];
    
    //为所有控件添加约束
    [self setConstraint];
    
}

- (void)didClikSelButton:(UIButton *)sender{
    
    ClassificationOfDiseaseController *ClassificationVc = [[ClassificationOfDiseaseController alloc]init];
    ClassificationVc.ClickButtonNumer = self.ClickButtonNumer;
    
    [self.navigationController pushViewController:ClassificationVc animated:YES];
    ClassificationVc.dtoBlock = ^(NSString *name){
        
        self.name = name;
        NSLog(@"self.name = %@",self.name);
    };
    WJLog(@"选择疾病细分");
}

- (void)didClikMoreSelButton:(UIButton *)sender{
    
    InessTableViewController *inessTableVC = [[InessTableViewController alloc]init];
    
    inessTableVC.cellBlock = ^(NSString *string){
        
        self.moreSelButton.string = string;
    };
    
    [self.navigationController pushViewController:inessTableVC animated:YES];
    
    WJLog(@"选择并发症");
}

#pragma mark -
#pragma mark -为所有控件添加约束
- (void)setConstraint{
    
    //userLabel
    [self.userLabel makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.mas_topLayoutGuideBottom).offset(20);
        make.leading.equalTo(self.view).offset(10);
        make.height.equalTo(30);
    }];
    
    //nameLabel
    [self.nameLabel makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self.userLabel.mas_centerY);
        make.leading.mas_equalTo(self.userLabel.mas_trailing).offset(10);
        make.height.equalTo(30);
    }];
    
    //typeLabel
    [self.typeLabel makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.userLabel.mas_bottom).offset(0);
        make.leading.mas_equalTo(self.userLabel.mas_leading).offset(0);
        make.height.equalTo(30);
    }];
    
    //diseseLabel
    [self.diseseLabel makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self.typeLabel.mas_centerY);
        make.leading.mas_equalTo(self.typeLabel.mas_trailing).offset(10);
        make.height.equalTo(30);
        
    }];
    
    //疾病细分
    [self.selDisButton makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.typeLabel.mas_bottom).offset(10);
        make.leading.equalTo(self.view).offset(10);
        make.trailing.equalTo(self.view).offset(-10);
        make.height.equalTo(40);
    }];
    
    //选择并发症
    [self.moreSelButton makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.selDisButton.mas_bottom).offset(15);
        make.leading.equalTo(self.view).offset(10);
        make.trailing.equalTo(self.view).offset(-10);
        make.height.equalTo(40);
    }];
    
    
}
@end
